﻿using Microsoft.Office.Tools.Ribbon;
using System;
using System.Deployment.Application;
using System.Reflection;
using System.Windows.Forms;
namespace DocFormatModi
{
    public partial class TecSpecFormatMerger 
    {
        private void Word_Load(object sender, RibbonUIEventArgs e)
        {

        }
        /// <summary>
        /// 导入文档
        /// </summary>
        private void button2_Click(object sender, RibbonControlEventArgs e)
        {
            try
            {
                // 使用单例模式获取 MergeDocDialog 实例
                MergeDocDialog.Instance.Show();

                // 如果窗口被最小化，恢复它
                if (MergeDocDialog.Instance.WindowState == FormWindowState.Minimized)
                {
                    MergeDocDialog.Instance.WindowState = FormWindowState.Normal;
                }

                // 将窗口带到前台
                MergeDocDialog.Instance.Activate();
            }
            catch (Exception ex)
            {
                MessageBox.Show($"打开合并文档对话框时发生错误：{ex.Message}",
                               "错误",
                               MessageBoxButtons.OK,
                               MessageBoxIcon.Error);
            }
        }
        //导入模板
        private void button1_Click(object sender, RibbonControlEventArgs e)
        {
            MessageBox.Show("导入模板");
        }
        //合并输出
        private void button4_Click(object sender, RibbonControlEventArgs e)
        {
            MessageBox.Show("合并输出");
        }
        //正文格式设置
        private void button3_Click(object sender, RibbonControlEventArgs e)
        {
            MessageBox.Show("正文格式设置");
        }
        //获取版本号
        private string GetDeploymentVersion()
        {
            if (ApplicationDeployment.IsNetworkDeployed) // 确保是通过 ClickOnce 部署
            {
                // 获取 ClickOnce 部署版本
                Version version = ApplicationDeployment.CurrentDeployment.CurrentVersion;
                return version.ToString();
            }
            else
            {
                return "未通过 ClickOnce 部署";
            }
        }
        private void button5_Click(object sender, RibbonControlEventArgs e)
        {
            string version = GetDeploymentVersion(); // 使用之前定义的方法获取版本号
            MessageBox.Show($"中铁装配技术标格式修改软件插件版本号：{version}", "版本信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
    }
}
